package com.todo.strategy.online.application.frontend.controller;

import com.todo.common.common.entity.response.BizResponse;
import com.todo.strategy.online.application.frontend.service.WantSetAggService;
import com.todo.strategy.online.iface.WantSetFrontendIface;
import com.todo.strategy.online.iface.request.*;
import com.todo.strategy.online.iface.response.WantSetDetailVO;
import com.todo.strategy.online.iface.response.WantSetInfoVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author azhebuxing
 * @date 2024/5/19 14:29
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/strategy")
@Tag(name = "我想去集合前台接口", description = "我想去集合前台接口")
public class WantSetFrontendController implements WantSetFrontendIface {

    @Resource
    private WantSetAggService wantSetAggService;


    @Override
    @Operation(summary = "新增我想去集合信息")
    @PostMapping("/insertWantSet")
    public BizResponse<Boolean> insertWantSet(InsertWantSetParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return wantSetAggService.insertWantSet(param);
    }

    @Override
    @Operation(summary = "删除我想去集合信息")
    @PostMapping("/removeWantSetById")
    public BizResponse<Boolean> removeWantSetById(RemoveWantSetParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return wantSetAggService.removeWantSetById(param);
    }

    @Override
    @Operation(summary = "更新我想去集合信息")
    @PostMapping("/updateWantSetById")
    public BizResponse<Boolean> updateWantSetById(UpdateWantSetParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return wantSetAggService.updateWantSetById(param);
    }

    @Override
    @Operation(summary = "根据用户id查询我想去集合信息列表")
    @PostMapping("/queryWantSetByUserId")
    public BizResponse<List<WantSetInfoVO>> queryWantSetByUserId(QueryWantSetByUserIdParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return wantSetAggService.queryWantSetByUserId(param);
    }

    @Override
    @Operation(summary = "插入我想去集合关联信息")
    @PostMapping("/insertWantSetRelation")
    public BizResponse<Boolean> insertWantSetRelation(InsertWantSetRelationParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return wantSetAggService.insertWantSetRelation(param);
    }

    @Override
    @Operation(summary = "删除我想去集合关联信息")
    @PostMapping("/removeWantSetRelation")
    public BizResponse<Boolean> removeWantSetRelation(RemoveWantSetRelationParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return wantSetAggService.removeWantSetRelation(param);
    }

    @Override
    @Operation(summary = "根据集合id查询我想去集合关联信息")
    @PostMapping("/queryWantSetRelationByWantId")
    public BizResponse<WantSetDetailVO> queryWantSetRelationByWantId(QueryWantSetRelationByWantIdParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return wantSetAggService.queryWantSetRelationByWantId(param);
    }
}
